package com.project.springboot.controller;

import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Locale;

/**
 * description: 登录控制器
 * @author 朱正磊
 * @date 2025-06-13 13:38:15
 */
@Slf4j
@Controller
@RequestMapping("/login")
public class LoginController {

    @Resource
    private MessageSource messageSource;

    @GetMapping("/login")
    public String login() {
        // 当前请求的语言环境
        Locale locale = LocaleContextHolder.getLocale();
        // 根据请求的语言环境来获取国际化配置信息
        String loginUserName = messageSource.getMessage("login.username", null, locale);
        // 打印
        log.info("Local={}, loginUserName={}", locale, loginUserName);

        return "login/login";
    }

}
